package com.db.compare.service.impl;

import com.db.compare.model.DbCompareReport;
import com.db.compare.mapper.DbCompareReportMapper;
import com.db.compare.service.DbCompareReportService;
import com.db.compare.vo.DbCompareReportVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DbCompareReportServiceImpl implements DbCompareReportService {
    @Autowired
    private DbCompareReportMapper dbcomparereportMapper;
    @Override
    public PageInfo<DbCompareReport> pageInfo(DbCompareReportVo dbcomparereportVo) {
        PageHelper.startPage(dbcomparereportVo.getPageNum(),dbcomparereportVo.getPageSize());
        List<DbCompareReport> dbcomparereportList = dbcomparereportMapper.findList(dbcomparereportVo);
        PageInfo<DbCompareReport> pageInfo = new PageInfo<>(dbcomparereportList);
        return pageInfo;
    }

    @Override
    public List<DbCompareReport> findList(DbCompareReportVo dbcomparereportVo) {
        List<DbCompareReport> dbcomparereportList = dbcomparereportMapper.findList(dbcomparereportVo);
        long now=System.currentTimeMillis();
        for(DbCompareReport dbCompareReport:dbcomparereportList){
            long time=dbCompareReport.getCreateTime();
            long juli=now-time;
            String timedesc=juli/60000+"mins";
            dbCompareReport.setTime(timedesc);
        }
        return dbcomparereportList;
    }
}
